Manager helping with path finding and resource loading. More...
Public Member Functions | |
void | setWorkingPath (const std::string_view &path) |
void | setWorkingPathAbsolute (const std::string_view &path) |
const char * | getWorkingPath () const |
const char * | getWorkingPathAbsolute () const |
const char * | getLaunchedPath () const |
void | setLaunchedPath (const std::string_view &path) |
std::string | getRelativeFromAbsolute (const std::string_view &absolutePath) const |
std::string | getAbsoluteFromRelative (const std::string_view &relativePath) const |
std::string | getRelativeFromWorkingDir (const std::string_view &workingPath) const |
std::string | getAbsoluteFromWorkingDir (const std::string_view &workingPath) const |
std::string | getFromWorkingDirFromRelative (const std::string_view &relativePath) const |
std::string | getFromWorkingDirFromAbsolute (const std::string_view &absolutePath) const |
bool | checkFileExists (const std::string_view &filePathAbs) const |
void | checkFolderExists (const char *path) |
std::vector< unsigned char > | loadFileIntoMemory (const std::string_view &filePathAbs, bool silent=false) |
Friends | |
class | nkCommon::SingletonClass< ResourceManager > |
Manager helping with path finding and resource loading.
It uses 3 keywords for all paths it manipulates :
Transformations from one path to another use these keywords :
void nkResources::ResourceManager::setWorkingPath | ( | const std::string_view & | path | ) |
Sets the working path.
path | The path of the wanted path, relative to the path from where the software is launched. |
void nkResources::ResourceManager::setWorkingPathAbsolute | ( | const std::string_view & | path | ) |
Sets the working path.
path | The path of the wanted path, absolute. |
const char* nkResources::ResourceManager::getWorkingPath | ( | ) | const |
const char* nkResources::ResourceManager::getWorkingPathAbsolute | ( | ) | const |
const char* nkResources::ResourceManager::getLaunchedPath | ( | ) | const |
void nkResources::ResourceManager::setLaunchedPath | ( | const std::string_view & | path | ) |
Allows to override the path from which the program is launched.
std::string nkResources::ResourceManager::getRelativeFromAbsolute | ( | const std::string_view & | absolutePath | ) | const |
Converts a path, from absolute, to a path relative to the launched path.
absolutePath | The absolute path to convert. |
std::string nkResources::ResourceManager::getAbsoluteFromRelative | ( | const std::string_view & | relativePath | ) | const |
Converts a path, from relative to the launched directory, to absolute.
relativePath | The relative path to convert. |
std::string nkResources::ResourceManager::getRelativeFromWorkingDir | ( | const std::string_view & | workingPath | ) | const |
Converts a path, from relative to the working directory, to relative to the launched path.
workingPath | The path relative to the working directoy to convert. |
std::string nkResources::ResourceManager::getAbsoluteFromWorkingDir | ( | const std::string_view & | workingPath | ) | const |
Converts a path, from relative to the working directory, to absolute.
workingPath | The path relative to the working directoy to convert. |
std::string nkResources::ResourceManager::getFromWorkingDirFromRelative | ( | const std::string_view & | relativePath | ) | const |
Converts a path, from relative to the launched directory, to relative to the working directory.
relativePath | The path relative to the launched path to convert. |
std::string nkResources::ResourceManager::getFromWorkingDirFromAbsolute | ( | const std::string_view & | absolutePath | ) | const |
Converts a path, from absolute, to relative to the working directory.
absolutePath | The absolute path to convert. |
bool nkResources::ResourceManager::checkFileExists | ( | const std::string_view & | filePathAbs | ) | const |
Checks if a file exists for a certain path.
filePathAbs | The absolute path to check. |
void nkResources::ResourceManager::checkFolderExists | ( | const char * | path | ) |
Checks if a folder exists for a certain path.
path | The absolute path to check. |
std::vector<unsigned char> nkResources::ResourceManager::loadFileIntoMemory | ( | const std::string_view & | filePathAbs, |
bool | silent = false |
||
) |
Loads a file into memory.
filePathAbs | The path to the file, absolute. |
silent | If a failure in finding the requested file should not be logged. True for no logging, false otherwise. |